//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "mission\init.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>
#include <modules\modules.hpp>

INFO("Starting Mission Framework Initialisation");

// We set the debug level at the lowest as a standard to avoid flooding client computers
// Debug Levels:
// Server Info: 1
// Server Debug: 2
// Server Trace: 3
// Client Info (+full server): 6
// Client Debug (+full server): 7
// Client Trace (+full server): 8

if (isnil "diag_debug_level") then { diag_debug_level = 0 };

GVAR(INIT) = false; GVAR(SERVER) = false; GVAR(CLIENT) = false; GVAR(JIP) = false; GVAR(SPE) = false; GVAR(MP) = isMultiplayer; GVAR(LOADED) = false; GVAR(PLAYER_INIT) = false;
if (isServer) then {
	GVAR(SERVER) = true;
	if (!isDedicated) then {
		GVAR(CLIENT) = true;
		GVAR(SPE) = true;
		[] spawn {waitUntil {!isNull player};GVAR(INIT) = true};
	} else {
		GVAR(INIT) = true;
	};
} else {
	GVAR(CLIENT) = true;
	if (isNull player) then {
		GVAR(JIP) = true;
		[] spawn {waitUntil {!isNull player};GVAR(INIT) = true};
	} else {
		GVAR(INIT) = true;
	};
};

// Stores all the events used on the machine
if (isNil QGVAR(event_holder)) then {GVAR(event_holder) = "Land_HelipadEmpty_F" createVehicleLocal [0, 0, 0];};
// Stores all the variables of the mission framework
if (isNil QGVAR(mission_store)) then {GVAR(mission_store) = "Land_HelipadEmpty_F" createVehicleLocal [0, 0, 0];};
// Stores all the variables of the mission framework
if (isNil QGVAR(mission_variables)) then {GVAR(mission_variables) = "Land_HelipadEmpty_F" createVehicleLocal [0, 0, 0];};
// Used to send global messages to the players
if (isNil QGVAR(GlobalChatLogic)) then {GVAR(GlobalChatLogic) = "Logic" createVehicleLocal [0,0,0]};

EXECNOW(TMF_PATH,"modules\tmf_core\main.sqf");

INFO("Ending Mission Framework Initialisation");
X_LOADED = true;